What’s the best way to implement caching in Python functions: globals parameters or classes